/**
 * Copyright (c) 快宝网络 kuaidihelp.com Co., Ltd. All Rights Reserved 禁止外泄以及用于其它的商业用途
 */

import { useCallback, useRef } from 'react';

export default () => {
  const actionRef = useRef({
    queryMap: {},
  });

  // 设置查询数据
  const setQuery = useCallback((pathname, query = {}) => {
    actionRef.current.queryMap[pathname] = query;
    return query;
  }, []);

  // 获取查询数据
  const getQuery = useCallback((pathname) => {
    return actionRef.current.queryMap[pathname] || {};
  }, []);

  return { setQuery, getQuery };
};
